//
//  MiniAppUtils.swift
//  Runner
//
//  Created by YMac on 04/05/2021.
//  Copyright © 2021 The Chromium Authors. All rights reserved.
//

class MiniAppUtils {
    static func callback_base(_ event: String, _ data: Any?, _ callback: @escaping DCUniMPKeepAliveCallback) {
        switch event {
        case "yGetHttpHeader":
            callback("""
            {
                "myHeader": "value1"
            }
            """, true)
            break
        default: break
        }
    }
    
    static func goMiniApp(viewController: YUIViewController, checkVersionJkid: String) {
        YUniappPlugin(viewController, checkVersionJkid: checkVersionJkid) { event, data, callback in
            switch event {
            case "myFunc1":
                viewController.yToast("自定义扩展函数：myFunc1")
            default: callback_base(event, data, callback)
            }
        }.run()
    }
}
